package org.liuyuantao.mongo;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;

public class HelloWorld {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		MongoClient mongoClient = new MongoClient();
		//查询所有的Database
        for (String name : mongoClient.getDatabaseNames()) {
            System.out.println("dbName: " + name);
        }
		MongoDatabase db = mongoClient.getDatabase("local");
		//查询所有的聚集集合
        for (String name : db.listCollectionNames()) {
            System.out.println("collectionName: " + name);
        }
		
	}
}
